package com.gtvtv.sparkdesksdk.model.request.agent;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

public class AgentRequestHistoryMessageObject {
    @JsonProperty("role")
    private final String role;

    @JsonProperty("content_type")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String contentType;

    @JsonProperty("content")
    private final String content;

    public AgentRequestHistoryMessageObject(String role, String content) {
        this(role, "text", content);
    }

    public AgentRequestHistoryMessageObject(String role, String contentType, String content) {
        if (!"user".equals(role) && !"assistant".equals(role)) {
            throw new IllegalArgumentException("role 必须是 'user' 或 'assistant'");
        }
        if (!"text".equals(contentType) && !"image".equals(contentType)) {
            throw new IllegalArgumentException("contentType 必须是 'text' 或 'image'");
        }

        this.role = role;
        this.contentType = contentType;
        this.content = content;
    }

    // Getters and Setters
    public String getRole() {
        return role;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        if (!"text".equals(contentType) && !"image".equals(contentType)) {
            throw new IllegalArgumentException("contentType 必须是 'text' 或 'image'");
        }
        this.contentType = contentType;
    }

    public String getContent() {
        return content;
    }
}